package com.test.service;


import com.test.comm.enums.MsgTypeEnum;
import com.test.comm.enums.RequestTypeEnum;
import com.test.comm.dto.Msg;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * Created by andy QQ 1525555556 on 2020/02/13
 */
@Service
public  abstract class DispatchService {


    public void disp(Msg msg) throws IOException {
        RequestTypeEnum requestTypeEnum = RequestTypeEnum.map.get(msg.getType());
        String msgTypeDesc = msg.getMsgType()==0 ? "未知": MsgTypeEnum.map.get(msg.getMsgType()).getDesc();
        System.out.println("收到msg，事件code: "+requestTypeEnum.getType()+" ("+requestTypeEnum.getDesc()+" - "+msgTypeDesc+") msg: "+msg.getMsg());
        switch (requestTypeEnum){
            //私聊
            case PRIVATE:
                privateMsg(msg);
                break;
            //群聊
            case GROUP:
                groupMsg(msg);
                break;
            //未知消息
            case UNKNOW:
                unknowMsg(msg);
                break;
            //新人进群
            case MEMBER_ADD:
                memberAdd(msg);
                break;
            case MEMBER_DEC:
                memberDec(msg);
                break;
            case VERFIGY:
                verfigy(msg);
                break;
            case SCAN_CASH_MONEY:
                scanCashMoney(msg);
                break;
            case TRANSFER:
                transfer(msg);
                break;
            case STARTUP:
                break;
            case LOGIN_SUCC:
                break;
            case LOGIN_OFF:
                break;
            default:
                break;
        }

    }

    /**
     * 功能描述: 私聊
     * @author: swc
     * @date: 2020/5/12 20:24
    */
    public  abstract void privateMsg(Msg msg) ;



    /**
     * 功能描述: 群聊
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public  abstract void groupMsg(Msg msg);

    /**
     * 功能描述: 未知消息
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public abstract void unknowMsg(Msg msg) ;

    /**
     * 功能描述: 新人入群
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public abstract void memberAdd(Msg msg);

    /**
     * 功能描述: 有人退群
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public  abstract void memberDec(Msg msg);

    /**
     * 功能描述: 好友请求验证
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public  abstract void verfigy(Msg msg);

    /**
     * 功能描述: 二维码收款
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public  abstract void scanCashMoney(Msg msg);

    /**
     * 功能描述: 好友转账
     * @author: swc
     * @date: 2020/5/12 20:24
     */
    public  abstract void transfer(Msg msg);

}
